package mockproject.fresher15.sd.util;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;

public class HibernateUtil {
	@PersistenceUnit
	 private static final EntityManagerFactory sessionFactory = buildSessionFactory();
	  
	    private static EntityManagerFactory buildSessionFactory() {
	        try {
	            // Create the SessionFactory from hibernate.cfg.xml
	            return  Persistence.createEntityManagerFactory("EntityFac");
	        } catch (Throwable ex) {
	            System.err.println("Initial SessionFactory creation failed." + ex);
	            throw new ExceptionInInitializerError(ex);
	        }
	    }
	 
	    public static EntityManagerFactory getSessionFactory() {
	        return sessionFactory;
	    }
}
